<template>
	<view class="page">
		<block v-if="url.length > 0">
			<web-view :webview-styles="webviewStyles" :src="url"></web-view>
		</block>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
	import { useUserInfoStore, useIndexStore } from '@/store/index';

	const userInfoStore = useUserInfoStore();
	const indexStore = useIndexStore();
	const url = ref('');
	const webviewStyles = ref({
		progress: {
			color: '#FF3333'
		}
	});

	onLoad(() => {
		let time = new Date().getTime();
		// url.value = `https://image.srea.org.cn/house-market-xcx-webview/map-houses/`;

		url.value = `https://image.srea.org.cn/house-market-xcx-webview/map-houses/?cityCode=${indexStore.nowCityCode}&time=${time}#wechat_redirect`;
	})

	// 分享到好友
	onShareAppMessage(() => {
		return {
			title: '新房超市-地图找房',
			path: `/pages/products/map/index?puid=${userInfoStore.userInfo.id}`,
			imageUrl: '',
		}
	})

	// 分享到朋友圈
	onShareTimeline(() => {
		return {
			title: '新房超市-地图找房',
			query: `puid=${userInfoStore.userInfo.id}`,
			imageUrl: '',
		}
	})
</script>

<style lang="scss" scoped>
</style>
